<template>
	<page>
		<view class="page">
			<view class="page__hd">
				<view class="page__title">{{newsDetail.title}}</view>
			</view>
			<view class="page__bd">
				<view class="weui-article">
					<u-parse :content="newsDetail.content" @preview="preview" @navigate="navigate"></u-parse>
				</view>
			</view>
		</view>
	</page>

</template>

<script>
	import app from '@/App.vue';
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js'
	import uParse from '@/components/uParse/src/wxParse.vue'
	//import uParse from '@/components/gaoyia-parse/parse.vue'
	export default {
		data() {
			return {
				newsDetail: {},
				time: '',
				// article:'',
			}
		},
		components: {
			uParse
		},
		onLoad(options) {
			let id = options.id;
			console.log('onload的值', id);
			this.getNewsDetail(id);
		},
		methods: {
			getNewsDetail: function(id) {
				uni.showLoading({
					title: '加载中',
				});
				gyzjModel.prototype.getNewsDetail(id).then(data => {

					console.log('执行的data', data);
					switch (data.code) {
						case 1:
							uni.hideLoading();
							var article = data.data.content;
							var that = this;
							// WxParse.wxParse('article', 'html', article, that, 5);
							let time = gyzjModel.prototype.formatTime(data.data.created_at, 2);
							this.newsDetail = data.data;
							this.time = time;
							break;
						default:
							uni.hideLoading();
							uni.showToast({
								title: data.message,
								icon: 'none',
							})
					}

				});
			},
			preview(src, e) {
				// do something
			},
			navigate(href, e) {
				// do something
			}
		},
		// data() {
		// 	return {
		// 		article: '<div>我是HTML代码</div><div>你們好嗎</div>'
		// 	}
		// },
		// methods: {
			
		// }
	}
</script>

<style>
	@import url("../../../components/uParse/src/wxParse.css");
	/* @import url("../../../components/u-parse/u-parse.css"); */
	image {
		max-width: 100%;
	}
	
	.page {
		background-color: #fff;
	}
	
	.ml-10 {
		margin-left: 10upx;
	}
	
	.page__hd {
		padding: 20upx 40upx 0;
	}
	
	.page__title {
		text-align: center;
	}
</style>
